﻿
namespace NetROS.Tiers.Windows.Forms
{
	/// <summary>
	/// abstract Organizacija typed datagridview
	/// </summary>
	[System.ComponentModel.DesignerCategoryAttribute("code")]
	public abstract class OrganizacijaDataGridViewBase : System.Windows.Forms.UserControl
	{	
		/// <summary> 
		/// Thrown when the current Entity changed.
		/// </summary>
		public event System.EventHandler<OrganizacijaDataGridViewEventArgs> CurrentEntityChanged;
		
		#region Fields
				
		/// <summary> 
		/// the current entity.
		/// </summary>
		private Entities.Organizacija _currentOrganizacija = null;
		//private Dictionary<string, string> _columnsHeaders = new Dictionary<string, string>();
		
		/// <summary> 
		/// the datagridview instance
		/// </summary>
		protected System.Windows.Forms.DataGridView uxOrganizacijaDataGridView;
		
		/// <summary> 
		/// the errorprovider
		/// </summary>
		protected System.Windows.Forms.ErrorProvider uxOrganizacijaErrorProvider;
		
		/// <summary> 
		/// the bindingsource
		/// </summary>
		protected System.Windows.Forms.BindingSource uxOrganizacijaBindingSource;
		
		
		/// <summary> 
		/// the DGV column associated with the ID property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxIDDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Naziv property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxNazivDataGridViewColumn;
		/// <summary> 
		/// the DGV column associated with the IDRoditelj property
		/// </summary>
		protected System.Windows.Forms.DataGridViewComboBoxColumn uxIDRoditeljDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Hierarchy property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxHierarchyDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Lvl property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxLvlDataGridViewColumn;
		/// <summary> 
		/// the DGV column associated with the IDTip property
		/// </summary>
		protected System.Windows.Forms.DataGridViewComboBoxColumn uxIDTipDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the SifraSkladista property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxSifraSkladistaDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Grupa property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxGrupaDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Telefon property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxTelefonDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Fax property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxFaxDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Adresa property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxAdresaDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the EMail property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxEMailDataGridViewColumn;
		/// <summary> 
		/// the DGV column associated with the IDMjesto property
		/// </summary>
		protected System.Windows.Forms.DataGridViewComboBoxColumn uxIDMjestoDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Direktor property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxDirektorDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Poreznibroj property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxPoreznibrojDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the OznakaDjelatnosti property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxOznakaDjelatnostiDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the NadleznaIspostavaPorUp property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxNadleznaIspostavaPorUpDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the OrgOIB property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxOrgOIBDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the CalculatedHierarchy property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxCalculatedHierarchyDataGridViewColumn;
		
		#endregion
					
		#region Combo list
		
				
		private Entities.TList<Entities.Mjesto> _IDMjestoList;
		
		/// <summary> 
		/// The list of selectable Mjesto
		/// </summary>
		[System.ComponentModel.Category("DropDownList BindingSources")]
		public Entities.TList<Entities.Mjesto> IDMjestoList
		{
			get {return this._IDMjestoList;}
			set 
			{
				this._IDMjestoList = value;
				this.uxIDMjestoDataGridViewColumn.DataSource = null;
				this.uxIDMjestoDataGridViewColumn.DataSource = this._IDMjestoList;
			}
		}
		
		private bool _allowNewItemInIDMjestoList;
		
		/// <summary> 
		/// Indicates if user can add an item in the list of Mjesto
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInIDMjestoList
		{
			get { return _allowNewItemInIDMjestoList;}
			set
			{
				this._allowNewItemInIDMjestoList = value;
				this.uxIDMjestoDataGridViewColumn.DisplayStyle = value ? System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox : System.Windows.Forms.DataGridViewComboBoxDisplayStyle.DropDownButton;
			}
		}
		
				
		private Entities.TList<Entities.Organizacija> _IDRoditeljList;
		
		/// <summary> 
		/// The list of selectable Organizacija
		/// </summary>
		[System.ComponentModel.Category("DropDownList BindingSources")]
		public Entities.TList<Entities.Organizacija> IDRoditeljList
		{
			get {return this._IDRoditeljList;}
			set 
			{
				this._IDRoditeljList = value;
				this.uxIDRoditeljDataGridViewColumn.DataSource = null;
				this.uxIDRoditeljDataGridViewColumn.DataSource = this._IDRoditeljList;
			}
		}
		
		private bool _allowNewItemInIDRoditeljList;
		
		/// <summary> 
		/// Indicates if user can add an item in the list of Organizacija
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInIDRoditeljList
		{
			get { return _allowNewItemInIDRoditeljList;}
			set
			{
				this._allowNewItemInIDRoditeljList = value;
				this.uxIDRoditeljDataGridViewColumn.DisplayStyle = value ? System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox : System.Windows.Forms.DataGridViewComboBoxDisplayStyle.DropDownButton;
			}
		}
		
				
		private Entities.TList<Entities.OrganizacijaTip> _IDTipList;
		
		/// <summary> 
		/// The list of selectable OrganizacijaTip
		/// </summary>
		[System.ComponentModel.Category("DropDownList BindingSources")]
		public Entities.TList<Entities.OrganizacijaTip> IDTipList
		{
			get {return this._IDTipList;}
			set 
			{
				this._IDTipList = value;
				this.uxIDTipDataGridViewColumn.DataSource = null;
				this.uxIDTipDataGridViewColumn.DataSource = this._IDTipList;
			}
		}
		
		private bool _allowNewItemInIDTipList;
		
		/// <summary> 
		/// Indicates if user can add an item in the list of OrganizacijaTip
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInIDTipList
		{
			get { return _allowNewItemInIDTipList;}
			set
			{
				this._allowNewItemInIDTipList = value;
				this.uxIDTipDataGridViewColumn.DisplayStyle = value ? System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox : System.Windows.Forms.DataGridViewComboBoxDisplayStyle.DropDownButton;
			}
		}
		
		#endregion
		
		#region Main Datasource
		
		private Entities.TList<Entities.Organizacija> _OrganizacijaList;
				
		/// <summary> 
		/// The list of Organizacija to be displayed in the DGV.
		/// </summary>
		[System.ComponentModel.Category("Data")]
		public Entities.TList<Entities.Organizacija> OrganizacijaList
		{
			get {return this._OrganizacijaList;}
			set
			{
				this._OrganizacijaList = value;
				this.uxOrganizacijaBindingSource.DataSource = null;
				this.uxOrganizacijaBindingSource.DataSource = value;
				this.uxOrganizacijaDataGridView.DataSource = null;
				this.uxOrganizacijaDataGridView.DataSource = this.uxOrganizacijaBindingSource;				
				//this.uxOrganizacijaBindingSource.ListChanged += new System.ComponentModel.ListChangedEventHandler(uxOrganizacijaBindingSource_ListChanged);
				this.uxOrganizacijaBindingSource.CurrentItemChanged += new System.EventHandler(OnOrganizacijaBindingSourceCurrentItemChanged);
			}
		}
		
		private void OnOrganizacijaBindingSourceCurrentItemChanged(object sender, System.EventArgs e)
		{
			_currentOrganizacija = uxOrganizacijaBindingSource.Current as Entities.Organizacija;
			
			if (_currentOrganizacija != null)
			{
				_currentOrganizacija.Validate();
			}
			//_Organizacija.Validate();
			OnCurrentEntityChanged();
		}

		//void uxOrganizacijaBindingSource_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
		//{
			//throw new Exception("The method or operation is not implemented.");
		//}		
		
		#endregion
		
		/// <summary>
		/// Gets the currently selected <c cref="Entities.Organizacija"/> instance.
		/// </summary>
		public Entities.Organizacija SelectedOrganizacija
		{
			get {return this._currentOrganizacija;}
		}
		
		#region other properties
		
		/// <summary>
		/// Gets or sets a value indicating whether you have provided your own data-management operations for the DataGridView control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool VirtualMode
		{
			get {return this.uxOrganizacijaDataGridView.VirtualMode;}
			set
			{
				this.uxOrganizacijaDataGridView.VirtualMode = value;
			}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the option to add rows is displayed to the user.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToAddRows
		{
			get {return this.uxOrganizacijaDataGridView.AllowUserToAddRows;}
			set {this.uxOrganizacijaDataGridView.AllowUserToAddRows = value;}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the user is allowed to delete rows from the DataGridView.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToDeleteRows
		{
			get {return this.uxOrganizacijaDataGridView.AllowUserToDeleteRows;}
			set {this.uxOrganizacijaDataGridView.AllowUserToDeleteRows = value;}
		}
		
		/// <summary>
		/// Gets the <c cref="DataGridView"/> instance.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public System.Windows.Forms.DataGridView DataGridView
		{
			get {return this.uxOrganizacijaDataGridView;}
		}
		
		/// <summary>
		/// Gets a collection that contains all the columns in the control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]		
		[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Visible)]
		//[System.ComponentModel.EditorAttribute("System.Windows.Forms.Design.DataGridViewColumnCollectionEditor, System.Design", typeof(System.Drawing.Design.UITypeEditor))] 
		public System.Windows.Forms.DataGridViewColumnCollection Columns
		{
			get { return this.uxOrganizacijaDataGridView.Columns; }
		}
		
		#endregion
		
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;
	
		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}
	
		#region Constructor
	
		/// <summary>
		/// Initializes a new instance of the <see cref="OrganizacijaDataGridViewBase"/> class.
		/// </summary>
		public OrganizacijaDataGridViewBase()
		{			
			this.components = new System.ComponentModel.Container();			
			
			this.uxOrganizacijaDataGridView = new System.Windows.Forms.DataGridView();
			this.uxOrganizacijaBindingSource = new System.Windows.Forms.BindingSource(this.components);
			this.uxOrganizacijaErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
			this.uxIDDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxNazivDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxIDRoditeljDataGridViewColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
			this.uxHierarchyDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxLvlDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxIDTipDataGridViewColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
			this.uxSifraSkladistaDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxGrupaDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxTelefonDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxFaxDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxAdresaDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxEMailDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxIDMjestoDataGridViewColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
			this.uxDirektorDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxPoreznibrojDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxOznakaDjelatnostiDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxNadleznaIspostavaPorUpDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxOrgOIBDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxCalculatedHierarchyDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			//this.uxIDMjestoBindingSource = new MjestoBindingSource(this.components);
			//((System.ComponentModel.ISupportInitialize)(this.uxIDMjestoBindingSource)).BeginInit();
			//this.uxIDRoditeljBindingSource = new OrganizacijaBindingSource(this.components);
			//((System.ComponentModel.ISupportInitialize)(this.uxIDRoditeljBindingSource)).BeginInit();
			//this.uxIDTipBindingSource = new OrganizacijaTipBindingSource(this.components);
			//((System.ComponentModel.ISupportInitialize)(this.uxIDTipBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxOrganizacijaDataGridView)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxOrganizacijaBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxOrganizacijaErrorProvider)).BeginInit();
			this.SuspendLayout();
						
			// 
			// uxOrganizacijaErrorProvider
			// 
			this.uxOrganizacijaErrorProvider.ContainerControl = this;
			this.uxOrganizacijaErrorProvider.DataSource = this.uxOrganizacijaBindingSource;						
			// 
			// uxOrganizacijaDataGridView
			// 
			this.uxOrganizacijaDataGridView.AutoGenerateColumns = false;
			this.uxOrganizacijaDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.uxOrganizacijaDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
		this.uxIDDataGridViewColumn,
		this.uxNazivDataGridViewColumn,
		this.uxIDRoditeljDataGridViewColumn,
		this.uxHierarchyDataGridViewColumn,
		this.uxLvlDataGridViewColumn,
		this.uxIDTipDataGridViewColumn,
		this.uxSifraSkladistaDataGridViewColumn,
		this.uxGrupaDataGridViewColumn,
		this.uxTelefonDataGridViewColumn,
		this.uxFaxDataGridViewColumn,
		this.uxAdresaDataGridViewColumn,
		this.uxEMailDataGridViewColumn,
		this.uxIDMjestoDataGridViewColumn,
		this.uxDirektorDataGridViewColumn,
		this.uxPoreznibrojDataGridViewColumn,
		this.uxOznakaDjelatnostiDataGridViewColumn,
		this.uxNadleznaIspostavaPorUpDataGridViewColumn,
		this.uxOrgOIBDataGridViewColumn,
		this.uxCalculatedHierarchyDataGridViewColumn			});
			this.uxOrganizacijaDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
			this.uxOrganizacijaDataGridView.Location = new System.Drawing.Point(0, 0);
			this.uxOrganizacijaDataGridView.Name = "uxOrganizacijaDataGridView";
			this.uxOrganizacijaDataGridView.Size = new System.Drawing.Size(470, 300);
			this.uxOrganizacijaDataGridView.TabIndex = 0;	
			this.uxOrganizacijaDataGridView.BackgroundColor = System.Drawing.Color.WhiteSmoke;
			this.uxOrganizacijaDataGridView.EnableHeadersVisualStyles = false;
			this.uxOrganizacijaDataGridView.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.OnOrganizacijaDataGridViewDataError);
			this.uxOrganizacijaDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnOrganizacijaDataGridViewCellValueNeeded);
			this.uxOrganizacijaDataGridView.CellValuePushed += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnOrganizacijaDataGridViewCellValuePushed);
			
			//
			// uxIDDataGridViewColumn
			//
			this.uxIDDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxIDDataGridViewColumn.DataPropertyName = "ID";
			this.uxIDDataGridViewColumn.HeaderText = "ID";
			this.uxIDDataGridViewColumn.Name = "uxIDDataGridViewColumn";
			this.uxIDDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxIDDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxIDDataGridViewColumn.ReadOnly = true;		
			//
			// uxNazivDataGridViewColumn
			//
			this.uxNazivDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxNazivDataGridViewColumn.DataPropertyName = "Naziv";
			this.uxNazivDataGridViewColumn.HeaderText = "Naziv";
			this.uxNazivDataGridViewColumn.Name = "uxNazivDataGridViewColumn";
			this.uxNazivDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxNazivDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxNazivDataGridViewColumn.ReadOnly = false;		
			//
			// uxIDRoditeljDataGridViewColumn
			//
			this.uxIDRoditeljDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxIDRoditeljDataGridViewColumn.DataPropertyName = "IDRoditelj";
			this.uxIDRoditeljDataGridViewColumn.HeaderText = "IDRoditelj";
			this.uxIDRoditeljDataGridViewColumn.Name = "uxIDRoditeljDataGridViewColumn";
			this.uxIDRoditeljDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxIDRoditeljDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxIDRoditeljDataGridViewColumn.ReadOnly = false;		
			//
			// uxHierarchyDataGridViewColumn
			//
			this.uxHierarchyDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxHierarchyDataGridViewColumn.DataPropertyName = "Hierarchy";
			this.uxHierarchyDataGridViewColumn.HeaderText = "Hierarchy";
			this.uxHierarchyDataGridViewColumn.Name = "uxHierarchyDataGridViewColumn";
			this.uxHierarchyDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxHierarchyDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxHierarchyDataGridViewColumn.ReadOnly = false;		
			//
			// uxLvlDataGridViewColumn
			//
			this.uxLvlDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxLvlDataGridViewColumn.DataPropertyName = "Lvl";
			this.uxLvlDataGridViewColumn.HeaderText = "Lvl";
			this.uxLvlDataGridViewColumn.Name = "uxLvlDataGridViewColumn";
			this.uxLvlDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxLvlDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxLvlDataGridViewColumn.ReadOnly = true;		
			//
			// uxIDTipDataGridViewColumn
			//
			this.uxIDTipDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxIDTipDataGridViewColumn.DataPropertyName = "IDTip";
			this.uxIDTipDataGridViewColumn.HeaderText = "IDTip";
			this.uxIDTipDataGridViewColumn.Name = "uxIDTipDataGridViewColumn";
			this.uxIDTipDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxIDTipDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxIDTipDataGridViewColumn.ReadOnly = false;		
			//
			// uxSifraSkladistaDataGridViewColumn
			//
			this.uxSifraSkladistaDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxSifraSkladistaDataGridViewColumn.DataPropertyName = "SifraSkladista";
			this.uxSifraSkladistaDataGridViewColumn.HeaderText = "SifraSkladista";
			this.uxSifraSkladistaDataGridViewColumn.Name = "uxSifraSkladistaDataGridViewColumn";
			this.uxSifraSkladistaDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxSifraSkladistaDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxSifraSkladistaDataGridViewColumn.ReadOnly = false;		
			//
			// uxGrupaDataGridViewColumn
			//
			this.uxGrupaDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxGrupaDataGridViewColumn.DataPropertyName = "Grupa";
			this.uxGrupaDataGridViewColumn.HeaderText = "Grupa";
			this.uxGrupaDataGridViewColumn.Name = "uxGrupaDataGridViewColumn";
			this.uxGrupaDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxGrupaDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxGrupaDataGridViewColumn.ReadOnly = false;		
			//
			// uxTelefonDataGridViewColumn
			//
			this.uxTelefonDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxTelefonDataGridViewColumn.DataPropertyName = "Telefon";
			this.uxTelefonDataGridViewColumn.HeaderText = "Telefon";
			this.uxTelefonDataGridViewColumn.Name = "uxTelefonDataGridViewColumn";
			this.uxTelefonDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxTelefonDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxTelefonDataGridViewColumn.ReadOnly = false;		
			//
			// uxFaxDataGridViewColumn
			//
			this.uxFaxDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxFaxDataGridViewColumn.DataPropertyName = "Fax";
			this.uxFaxDataGridViewColumn.HeaderText = "Fax";
			this.uxFaxDataGridViewColumn.Name = "uxFaxDataGridViewColumn";
			this.uxFaxDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxFaxDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxFaxDataGridViewColumn.ReadOnly = false;		
			//
			// uxAdresaDataGridViewColumn
			//
			this.uxAdresaDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxAdresaDataGridViewColumn.DataPropertyName = "Adresa";
			this.uxAdresaDataGridViewColumn.HeaderText = "Adresa";
			this.uxAdresaDataGridViewColumn.Name = "uxAdresaDataGridViewColumn";
			this.uxAdresaDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxAdresaDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxAdresaDataGridViewColumn.ReadOnly = false;		
			//
			// uxEMailDataGridViewColumn
			//
			this.uxEMailDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxEMailDataGridViewColumn.DataPropertyName = "EMail";
			this.uxEMailDataGridViewColumn.HeaderText = "EMail";
			this.uxEMailDataGridViewColumn.Name = "uxEMailDataGridViewColumn";
			this.uxEMailDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxEMailDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxEMailDataGridViewColumn.ReadOnly = false;		
			//
			// uxIDMjestoDataGridViewColumn
			//
			this.uxIDMjestoDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxIDMjestoDataGridViewColumn.DataPropertyName = "IDMjesto";
			this.uxIDMjestoDataGridViewColumn.HeaderText = "IDMjesto";
			this.uxIDMjestoDataGridViewColumn.Name = "uxIDMjestoDataGridViewColumn";
			this.uxIDMjestoDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxIDMjestoDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxIDMjestoDataGridViewColumn.ReadOnly = false;		
			//
			// uxDirektorDataGridViewColumn
			//
			this.uxDirektorDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxDirektorDataGridViewColumn.DataPropertyName = "Direktor";
			this.uxDirektorDataGridViewColumn.HeaderText = "Direktor";
			this.uxDirektorDataGridViewColumn.Name = "uxDirektorDataGridViewColumn";
			this.uxDirektorDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxDirektorDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxDirektorDataGridViewColumn.ReadOnly = false;		
			//
			// uxPoreznibrojDataGridViewColumn
			//
			this.uxPoreznibrojDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxPoreznibrojDataGridViewColumn.DataPropertyName = "Poreznibroj";
			this.uxPoreznibrojDataGridViewColumn.HeaderText = "Poreznibroj";
			this.uxPoreznibrojDataGridViewColumn.Name = "uxPoreznibrojDataGridViewColumn";
			this.uxPoreznibrojDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxPoreznibrojDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxPoreznibrojDataGridViewColumn.ReadOnly = false;		
			//
			// uxOznakaDjelatnostiDataGridViewColumn
			//
			this.uxOznakaDjelatnostiDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxOznakaDjelatnostiDataGridViewColumn.DataPropertyName = "OznakaDjelatnosti";
			this.uxOznakaDjelatnostiDataGridViewColumn.HeaderText = "OznakaDjelatnosti";
			this.uxOznakaDjelatnostiDataGridViewColumn.Name = "uxOznakaDjelatnostiDataGridViewColumn";
			this.uxOznakaDjelatnostiDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxOznakaDjelatnostiDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxOznakaDjelatnostiDataGridViewColumn.ReadOnly = false;		
			//
			// uxNadleznaIspostavaPorUpDataGridViewColumn
			//
			this.uxNadleznaIspostavaPorUpDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxNadleznaIspostavaPorUpDataGridViewColumn.DataPropertyName = "NadleznaIspostavaPorUp";
			this.uxNadleznaIspostavaPorUpDataGridViewColumn.HeaderText = "NadleznaIspostavaPorUp";
			this.uxNadleznaIspostavaPorUpDataGridViewColumn.Name = "uxNadleznaIspostavaPorUpDataGridViewColumn";
			this.uxNadleznaIspostavaPorUpDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxNadleznaIspostavaPorUpDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxNadleznaIspostavaPorUpDataGridViewColumn.ReadOnly = false;		
			//
			// uxOrgOIBDataGridViewColumn
			//
			this.uxOrgOIBDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxOrgOIBDataGridViewColumn.DataPropertyName = "OrgOIB";
			this.uxOrgOIBDataGridViewColumn.HeaderText = "OrgOIB";
			this.uxOrgOIBDataGridViewColumn.Name = "uxOrgOIBDataGridViewColumn";
			this.uxOrgOIBDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxOrgOIBDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxOrgOIBDataGridViewColumn.ReadOnly = false;		
			//
			// uxCalculatedHierarchyDataGridViewColumn
			//
			this.uxCalculatedHierarchyDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxCalculatedHierarchyDataGridViewColumn.DataPropertyName = "CalculatedHierarchy";
			this.uxCalculatedHierarchyDataGridViewColumn.HeaderText = "CalculatedHierarchy";
			this.uxCalculatedHierarchyDataGridViewColumn.Name = "uxCalculatedHierarchyDataGridViewColumn";
			this.uxCalculatedHierarchyDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxCalculatedHierarchyDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxCalculatedHierarchyDataGridViewColumn.ReadOnly = true;		
			//
			// uxIDMjestoDataGridViewColumn
			//				
			this.uxIDMjestoDataGridViewColumn.DisplayMember = "Naziv";	
			this.uxIDMjestoDataGridViewColumn.ValueMember = "ID";	
			this.uxIDMjestoDataGridViewColumn.DisplayStyleForCurrentCellOnly = true;
			//uxIDMjestoDataGridViewColumn.DataSource = uxIDMjestoBindingSource;				
				
			//
			// uxIDRoditeljDataGridViewColumn
			//				
			this.uxIDRoditeljDataGridViewColumn.DisplayMember = "Naziv";	
			this.uxIDRoditeljDataGridViewColumn.ValueMember = "ID";	
			this.uxIDRoditeljDataGridViewColumn.DisplayStyleForCurrentCellOnly = true;
			//uxIDRoditeljDataGridViewColumn.DataSource = uxIDRoditeljBindingSource;				
				
			//
			// uxIDTipDataGridViewColumn
			//				
			this.uxIDTipDataGridViewColumn.DisplayMember = "Naziv";	
			this.uxIDTipDataGridViewColumn.ValueMember = "ID";	
			this.uxIDTipDataGridViewColumn.DisplayStyleForCurrentCellOnly = true;
			//uxIDTipDataGridViewColumn.DataSource = uxIDTipBindingSource;				
				
			
			// this
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.Controls.Add(this.uxOrganizacijaDataGridView);
			this.Name = "OrganizacijaDataGridView";
			this.Size = new System.Drawing.Size(470, 300);
			//((System.ComponentModel.ISupportInitialize)(this.uxIDMjestoBindingSource)).EndInit();
			//((System.ComponentModel.ISupportInitialize)(this.uxIDRoditeljBindingSource)).EndInit();
			//((System.ComponentModel.ISupportInitialize)(this.uxIDTipBindingSource)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxOrganizacijaErrorProvider)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxOrganizacijaDataGridView)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxOrganizacijaBindingSource)).EndInit();
			this.ResumeLayout(false);
		}
		#endregion
				
		#region events
		
		/// <summary>
		/// Raised the CurrentEntityChanged event.
		/// </summary>
		protected void OnCurrentEntityChanged()
		{
			if (CurrentEntityChanged != null)
			{
				OrganizacijaDataGridViewEventArgs args = new OrganizacijaDataGridViewEventArgs();
				args.Organizacija = _currentOrganizacija;
				CurrentEntityChanged(this, args); 
			}
		}
		
		#endregion
		
		/// <summary>
		/// Strongly typed event 
		/// </summary>
		public class OrganizacijaDataGridViewEventArgs : System.EventArgs
		{
			private Entities.Organizacija	_Organizacija;
	
			/// <summary>
			/// the  Entities.Organizacija instance.
			/// </summary>
			public Entities.Organizacija Organizacija
			{
				get { return _Organizacija; }
				set { _Organizacija = value; }
			}	
		}
		
		/// <summary>
		/// Handles the DataError event of the uxOrganizacijaDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewDataErrorEventArgs"/> instance containing the event data.</param>
		protected void OnOrganizacijaDataGridViewDataError(object sender, System.Windows.Forms.DataGridViewDataErrorEventArgs e)
		{
			System.Diagnostics.Debug.WriteLine(string.Format( "{0}, {1}", e.ColumnIndex, e.RowIndex));
		}
		
		/// <summary>
		/// Handles the CellValueNeeded event of the uxOrganizacijaDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnOrganizacijaDataGridViewCellValueNeeded(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxOrganizacijaDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxIDDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].ID;
						break;
					case "uxNazivDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].Naziv;
						break;
					case "uxIDRoditeljDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].IDRoditelj;
						break;
					case "uxHierarchyDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].Hierarchy;
						break;
					case "uxLvlDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].Lvl;
						break;
					case "uxIDTipDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].IDTip;
						break;
					case "uxSifraSkladistaDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].SifraSkladista;
						break;
					case "uxGrupaDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].Grupa;
						break;
					case "uxTelefonDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].Telefon;
						break;
					case "uxFaxDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].Fax;
						break;
					case "uxAdresaDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].Adresa;
						break;
					case "uxEMailDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].EMail;
						break;
					case "uxIDMjestoDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].IDMjesto;
						break;
					case "uxDirektorDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].Direktor;
						break;
					case "uxPoreznibrojDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].Poreznibroj;
						break;
					case "uxOznakaDjelatnostiDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].OznakaDjelatnosti;
						break;
					case "uxNadleznaIspostavaPorUpDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].NadleznaIspostavaPorUp;
						break;
					case "uxOrgOIBDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].OrgOIB;
						break;
					case "uxCalculatedHierarchyDataGridViewColumn":
						e.Value = OrganizacijaList[e.RowIndex].CalculatedHierarchy;
						break;
				default:
				break;
			}
		}
		
		/// <summary>
		/// Handles the CellValuePushed event of the uxOrganizacijaDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnOrganizacijaDataGridViewCellValuePushed(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxOrganizacijaDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxIDDataGridViewColumn":
						OrganizacijaList[e.RowIndex].ID = (System.Int32)e.Value;
						break;
					case "uxNazivDataGridViewColumn":
						OrganizacijaList[e.RowIndex].Naziv = (System.String)e.Value;
						break;
					case "uxIDRoditeljDataGridViewColumn":
						OrganizacijaList[e.RowIndex].IDRoditelj = (System.Int32?)e.Value;
						break;
					case "uxHierarchyDataGridViewColumn":
						OrganizacijaList[e.RowIndex].Hierarchy = (System.String)e.Value;
						break;
					case "uxLvlDataGridViewColumn":
						OrganizacijaList[e.RowIndex].Lvl = (System.Int32?)e.Value;
						break;
					case "uxIDTipDataGridViewColumn":
						OrganizacijaList[e.RowIndex].IDTip = (System.Int32)e.Value;
						break;
					case "uxSifraSkladistaDataGridViewColumn":
						OrganizacijaList[e.RowIndex].SifraSkladista = (System.String)e.Value;
						break;
					case "uxGrupaDataGridViewColumn":
						OrganizacijaList[e.RowIndex].Grupa = (System.String)e.Value;
						break;
					case "uxTelefonDataGridViewColumn":
						OrganizacijaList[e.RowIndex].Telefon = (System.String)e.Value;
						break;
					case "uxFaxDataGridViewColumn":
						OrganizacijaList[e.RowIndex].Fax = (System.String)e.Value;
						break;
					case "uxAdresaDataGridViewColumn":
						OrganizacijaList[e.RowIndex].Adresa = (System.String)e.Value;
						break;
					case "uxEMailDataGridViewColumn":
						OrganizacijaList[e.RowIndex].EMail = (System.String)e.Value;
						break;
					case "uxIDMjestoDataGridViewColumn":
						OrganizacijaList[e.RowIndex].IDMjesto = (System.Int32?)e.Value;
						break;
					case "uxDirektorDataGridViewColumn":
						OrganizacijaList[e.RowIndex].Direktor = (System.String)e.Value;
						break;
					case "uxPoreznibrojDataGridViewColumn":
						OrganizacijaList[e.RowIndex].Poreznibroj = (System.String)e.Value;
						break;
					case "uxOznakaDjelatnostiDataGridViewColumn":
						OrganizacijaList[e.RowIndex].OznakaDjelatnosti = (System.String)e.Value;
						break;
					case "uxNadleznaIspostavaPorUpDataGridViewColumn":
						OrganizacijaList[e.RowIndex].NadleznaIspostavaPorUp = (System.String)e.Value;
						break;
					case "uxOrgOIBDataGridViewColumn":
						OrganizacijaList[e.RowIndex].OrgOIB = (System.String)e.Value;
						break;
					case "uxCalculatedHierarchyDataGridViewColumn":
						OrganizacijaList[e.RowIndex].CalculatedHierarchy = (System.String)e.Value;
						break;
				default:
				break;
			}
		}
	}
}
